package logistics;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;

public class ResourceAllocation extends JPanel {
  private JTable table;
    private JTextArea textArea;

	/**
	 * Create the panel.
	 */
	public ResourceAllocation() {
		setLayout(null);

		JPanel panel = new JPanel();
		panel.setBounds(30, 59, 670, 283);
		add(panel);
		panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

		JScrollPane scrollPane = new JScrollPane();
		panel.add(scrollPane);

		table = new JTable();
		table.setModel(new DefaultTableModel(
				new Object[][] { { null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null }, { null, null, null, null,
								null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null },
						{ null, null, null, null, null }, { null, null, null, null, null }, },
				new String[] { "\u7F16\u53F7", "\u540D\u79F0", "\u529E\u516C\u5BA4\u53F7", "\u767B\u8BB0\u4EBA",
						"\u662F\u5426\u5728\u5E93" }));
		table.getColumnModel().getColumn(0).setPreferredWidth(100);
		table.getColumnModel().getColumn(1).setPreferredWidth(100);
		table.getColumnModel().getColumn(2).setPreferredWidth(100);
		table.getColumnModel().getColumn(3).setPreferredWidth(100);
		table.getColumnModel().getColumn(4).setPreferredWidth(100);
		scrollPane.setViewportView(table);

		JPanel panel_1 = new JPanel();
		panel_1.setBounds(30, 366, 670, 34);
		add(panel_1);

		JButton button = new JButton("入库");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				new RuKu();

			}
		});

		JButton button_1 = new JButton("报废");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});

		JButton button_2 = new JButton("调用");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
		panel_1.add(button);
		panel_1.add(button_1);
		panel_1.add(button_2);

		JPanel panel_2 = new JPanel();
		panel_2.setBounds(30, 10, 670, 39);
		add(panel_2);
		panel_2.setLayout(null);

		JButton btnNewButton = new JButton("点击查询");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			}
		});
		btnNewButton.setBounds(467, 10, 93, 23);
		panel_2.add(btnNewButton);

		 textArea = new JTextArea();

		textArea.addFocusListener(new FocusListener() {
		
			public void focusLost(FocusEvent e) {
				
				textArea.setText("请输入所需查询物品");
				
			}
			
			@Override
			public void focusGained(FocusEvent e) {
				
				textArea.setText("");
				
			}
		});
		textArea.setText("\u8BF7\u8F93\u5165\u6240\u9700\u67E5\u8BE2\u7269\u54C1");
		textArea.setBounds(136, 10, 311, 23);
		panel_2.add(textArea);

	}
public	class RuKu extends JFrame {

		private JPanel contentPane;
		private JTextField textField;
		private JTextField textField_1;
		private JTextField textField_3;
		private JTextField textField_2;
		private JTextField textField_4;
		private JTextField textField_5;
		private JPanel panel_2;

		public RuKu() {
			this.setVisible(true);
			setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			setBounds(100, 100, 405, 248);
			contentPane = new JPanel();
			contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
			setContentPane(contentPane);
			contentPane.setLayout(null);

			JPanel panel = new JPanel();
			panel.setBounds(0, 0, 389, 51);
			contentPane.add(panel);

			JLabel lblNewLabel_2 = new JLabel("\u7F16      \u53F7\uFF1A   ");

			textField_2 = new JTextField();
			textField_2.setColumns(10);
			panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
			panel.add(lblNewLabel_2);
			panel.add(textField_2);

			JPanel panel_1 = new JPanel();
			panel_1.setBounds(0, 171, 389, 43);
			contentPane.add(panel_1);
			panel_1.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

			JButton btnNewButton = new JButton(" \u786E\u5B9A ");
			panel_1.add(btnNewButton);

			JButton btnNewButton_1 = new JButton(" \u53D6\u6D88 ");
			panel_1.add(btnNewButton_1);

			panel_2 = new JPanel();
			panel_2.setBounds(0, 50, 389, 59);
			contentPane.add(panel_2);
			panel_2.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

			JLabel lblNewLabel_4 = new JLabel("\u540D      \u79F0\uFF1A  ");
			panel_2.add(lblNewLabel_4);

			textField_4 = new JTextField();
			panel_2.add(textField_4);
			textField_4.setColumns(10);

			JPanel panel_3 = new JPanel();
			panel_3.setBounds(0, 107, 389, 43);
			contentPane.add(panel_3);
			panel_3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

			JLabel lblNewLabel_5 = new JLabel("\u767B  \u8BB0  \u4EBA\uFF1A ");
			panel_3.add(lblNewLabel_5);

			textField_5 = new JTextField();
			panel_3.add(textField_5);
			textField_5.setColumns(10);

			JLabel lblNewLabel = new JLabel("\u7F16\u53F7\uFF1A");

			textField = new JTextField();
			textField.setColumns(10);

			JLabel lblNewLabel_1 = new JLabel("\u540D\u79F0\uFF1A");

			textField_1 = new JTextField();
			textField_1.setColumns(10);

			JLabel lblNewLabel_3 = new JLabel("\u767B\u8BB0\u4EBA\uFF1A");

			textField_3 = new JTextField();
			textField_3.setColumns(10);
			btnNewButton.addActionListener(new ActionListener() {
				
				public void actionPerformed(ActionEvent e) {
					data();
					RuKu.this.dispose();
				}
			});

		}
		public void data(){
			String number = textField_2.getText();
			String name = textField_4.getText();
			String people = textField_5.getText();
			
			table.setValueAt(number, 0, 0);
			table.setValueAt(name, 0, 1);
			table.setValueAt("仓库", 0, 2);
			table.setValueAt(people, 0, 3);
			table.setValueAt("在库", 0, 4);
		}
	}

}

